import React, { Component } from 'react';
import { Layout, Menu, Row } from 'antd';
import { Link } from 'react-router-dom';
import icon from './img/icon.png';
import './index.less';

const { Header } = Layout;
const { Item, SubMenu } = Menu;

class Nav extends Component {
  constructor(props) {
    super(props);
    const hash = window.location.hash.split('/')[1];
    this.state = { current: hash ? hash : 'Project' };
  }

  handleClick = (e) => {
    this.setState({
      current: e.key,
    });
  };

  render() {
    return (
      <div style={{ width: 80, height: '100%', zIndex: 999 }}>
        <div className="iconContainer">
          <img src={icon} className="icon" />
          {/* <span className="titleText">WR</span> */}
        </div>
        <Menu
          defaultSelectedKeys={['1']}
          defaultOpenKeys={['sub1']}
          mode="inline"
          theme="dark"
          inlineCollapsed={this.state.collapsed}
          selectedKeys={[this.state.current]}
          onClick={this.handleClick}
        >
          <Item key="Project">
            <Link to="/">项目</Link>
          </Item>
          <Item key="tests">
            <Link to="/tests">脚本</Link>
          </Item>
          <Item key="reports">
            <Link to="/reports">报告</Link>
          </Item>
          <Item key="setting">
            <Link to="/setting">设置</Link>
          </Item>
          <Item key="about">
            <Link to="/about">关于</Link>
          </Item>
        </Menu>
      </div>
    );
  }
}

export default Nav;
